<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <img class="outline-parent-bg" :src="publicUrls + 'free/style11/Auxiliaryoutlinestyle3Bg.webp'" alt="" />
    <div
      class="outline border-hover-style"
      :class="!props.info.value ? 'outline-width' : !props.info.remarks && !props.info.subTitle && 'outline-width-no'"
    >
      <div
        class="audio-box"
        :class="isPlay && 'audio-rotate'"
        v-if="props.info.audio && props.info.audio.url"
        @click="audioplay(true)"
      ></div>
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
      <div class="content-box">
        <div
          class="content-item"
          v-if="props.info.value || (props.info.video && props.info.video.url)"
          :style="!props.info.subTitle && !props.info.remarks && { marginRight: '0', width: '100%' }"
          :class="props.info.remarks && 'outline-cover-height'"
        >
          <div class="outline-title" v-if="!props.info.subTitle && !props.info.remarks">
            {{ props.info.text }}
          </div>
          <div class="medium">
            <img
              v-if="props.info.value && !(props.info.video && props.info.video.url)"
              class="outline-cover"
              @click="ImgVisible = true"
              :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
              alt=""
            />
            <videoview @click="audioplay(false)" :info="props.info"></videoview>
          </div>
        </div>
        <div
          class="outline-content"
          v-if="props.info.subTitle || props.info.remarks"
          :style="!props.info.value && !(props.info.video && props.info.video.url) && { width: '100%' }"
        >
          <div class="outline-title">
            {{ props.info.text }}
          </div>
          <p class="outline-subTitle" v-if="props.info.subTitle">——{{ props.info.subTitle }}</p>
          <TextMax
            v-if="props.domShow"
            :class="!props.info.value && 'TextMax-lineHeight'"
            :data="props.info.remarks"
            :title="props.info.text"
            :infoData="props.info"
            :row="
              props.info.value && props.info.subTitle
                ? 4
                : !props.info.value && props.info.subTitle
                ? 4
                : !props.info.subTitle && 5
            "
          ></TextMax>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free11Style3',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 220px linear-gradient(transparent, rgba(0, 0, 0, 0.2));
  margin: 0 80px;
}
.outline-parent-bg {
  width: 710px;
  height: 440px;
  margin-top: 50px;
  margin-right: 10px;
}
.outline-width {
  padding: 154px 75px 60px 75px !important;
}
.outline-width-no {
  padding: 154px 85px 60px 85px !important;
}
.outline {
  position: absolute;
  top: 50px;
  left: 0;
  z-index: 20;
  width: 710px;
  height: 440px;
  padding: 154px 110px 60px 110px;
  display: flex;
  align-items: center;
  flex-direction: column;
}

.outline-content {
  display: flex;
  align-items: center;
  justify-content: start;
  flex-direction: column;
  width: 320px;
  height: 100%;
  overflow: hidden;
  flex-shrink: 0;
}
.outline-title {
  width: 100%;
  font-family: 'SourceHanSerifCN-Bold';
  font-size: 20px;
  color: #ffecc3;
  line-height: 30px;
  text-shadow: 0px 5px 3px rgba(0, 0, 0, 0.2), 0px 2px 0px #ab997b;
  text-align: center;
  margin-bottom: 8px;
}
.outline-subTitle {
  width: 100%;
  font-family: PingFangSC;
  font-size: 16px;
  color: #fff;
  line-height: 28px;
  text-align: center;
  margin-bottom: 16px;
}
.content-box {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
  justify-content: center;
}
.outline-cover-height {
  height: 200px !important;
  margin-top: 19px;
}
.content-item {
  // width: 100%;
  width: 160px;
  height: 100%;
  margin-right: 10px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  .outline-title {
    margin-bottom: 16px !important;
  }
}
.medium {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #a29174;
  // &:hover .outline-cover {
  //   transform: scale(1.2);
  // }
  ::v-deep .mask-layer {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 50%;
    transform: translate(0%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    .round {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 2px solid rgba(255, 255, 255, 1);
      text-align: center;
      .freeIcon {
        font-size: 24px;
        line-height: 38px;
        color: rgba(255, 255, 255, 1);
      }
    }
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    overflow: hidden;
    transition: all 0.3s ease;
  }
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}
.audio-box {
  position: absolute;
  top: 50px;
  right: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: url(https://static.jiyi.show/free/style11/playIcon.webp) no-repeat center/100% 100%;
}
.TextMax-lineHeight {
  ::v-deep .van-text-ellipsis {
    line-height: 200% !important;
  }
}
::v-deep .textMore-box {
  flex: 1;
  display: flex;
  align-items: center;
}
::v-deep .van-text-ellipsis {
  font-family: PingFangSC !important;
  font-size: 16px !important;
  color: #fff !important;
  line-height: 180% !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: #ffecc3 !important;
  font-weight: 400 !important;
  text-decoration-line: underline;
}
</style>
